﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using blong.WebControls;

namespace AnyOffice.general.hrms.statistic
{
    public partial class index : ModulePage
    {
        private string strTemp;
        private WebChartItem webChartItem;
        private SqlCommand sqlCmd;
        private HrmsDao hrmsDao;
        private int count;
        private DataTable dataTable;


        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.Conn.State == ConnectionState.Closed)
            {
                base.Conn.Open();
            }
            this.strTemp = "select count(UserId) from hrms";
            this.sqlCmd = new SqlCommand(this.strTemp, base.Conn);
            this.count = (int)this.sqlCmd.ExecuteScalar();
            this.hrmsDao = new HrmsDao();
            this.dataTable = this.hrmsDao.StatisticForAge(base.Conn);
            this.chartAge.Title = "按年龄统计（共" + this.count.ToString() + "人）";
            if (this.dataTable.Rows.Count > 0)
            {
                for (int i = 0; i < this.dataTable.Rows.Count; i++)
                {
                    this.webChartItem = new WebChartItem();
                    this.webChartItem.PieLabel = this.dataTable.Rows[i]["Title"].ToString();
                    this.webChartItem.PrimaryValue = float.Parse(this.dataTable.Rows[i]["Num"].ToString());
                    this.chartAge.WebChartItems.Add(this.webChartItem);
                }
            }
            this.dataTable = this.hrmsDao.StatisticForEducation(base.Conn);
            this.chartEducation.Title = "按学历统计（共" + this.count.ToString() + "人）";
            if (this.dataTable.Rows.Count > 0)
            {
                for (int j = 0; j < this.dataTable.Rows.Count; j++)
                {
                    this.webChartItem = new WebChartItem();
                    this.webChartItem.PieLabel = this.dataTable.Rows[j]["Title"].ToString();
                    this.webChartItem.PrimaryValue = float.Parse(this.dataTable.Rows[j]["Num"].ToString());
                    this.chartEducation.WebChartItems.Add(this.webChartItem);
                }
            }
            this.dataTable = this.hrmsDao.StatisticForSex(base.Conn);
            this.chartSex.Title = "按性别统计（共" + this.count.ToString() + "人）";
            if (this.dataTable.Rows.Count > 0)
            {
                for (int k = 0; k < this.dataTable.Rows.Count; k++)
                {
                    this.webChartItem = new WebChartItem();
                    this.webChartItem.PieLabel = this.dataTable.Rows[k]["Title"].ToString();
                    this.webChartItem.PrimaryValue = float.Parse(this.dataTable.Rows[k]["Num"].ToString());
                    this.chartSex.WebChartItems.Add(this.webChartItem);
                }
            }
            this.dataTable = this.hrmsDao.StatisticForPolitics(base.Conn);
            this.chartPolitics.Title = "按政治面貌统计（共" + this.count.ToString() + "人）";
            if (this.dataTable.Rows.Count > 0)
            {
                for (int m = 0; m < this.dataTable.Rows.Count; m++)
                {
                    this.webChartItem = new WebChartItem();
                    this.webChartItem.PieLabel = this.dataTable.Rows[m]["Title"].ToString();
                    this.webChartItem.PrimaryValue = float.Parse(this.dataTable.Rows[m]["Num"].ToString());
                    this.chartPolitics.WebChartItems.Add(this.webChartItem);
                }
            }
        }


    }
}
